//
//  GDTabBarButton.m
//  GDWeiboNJ
//
//  Created by zhouguodong on 15/4/3.
//  Copyright (c) 2015年 shuanyuan. All rights reserved.
//

#import "GDTabBarButton.h"
#import "UIView+Frame.h"
@implementation GDTabBarButton

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setup];
    }
    return self;
}
// 通过xib/Storboard创建时调用
- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        [self setup];
    }
    return self;
}

- (void)setup
{
    // 设置图片居中
    self.imageView.contentMode = UIViewContentModeCenter;
    // 设置标题居中
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    // 设置文字字体大小
    self.titleLabel.font = [UIFont systemFontOfSize:13];
    
    // 设置按钮标题的颜色
    [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
    
}

// 返回内部图片位置的方法
- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
    CGFloat imageX = 0;
    CGFloat imageY = 0;
    CGFloat imageW = contentRect.size.width;
    CGFloat imageH = contentRect.size.height * 0.6;
    
    return CGRectMake(imageX, imageY, imageW, imageH);
}
// 返回内部标题位置的方法
- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
    CGFloat titleX = 0;
    CGFloat titleY = contentRect.size.height * 0.6;
    CGFloat titleW = contentRect.size.width;
    CGFloat titleH = contentRect.size.height  - contentRect.size.height * 0.6;
    return CGRectMake(titleX, titleY, titleW, titleH);
    
}

-(void)setHighlighted:(BOOL)highlighted
{
    
}

@end
